
//
//  PMineWalletViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/23.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PMineWalletViewController.h"
#import "LYSettingCell.h"


#import "LYRecruitmentController.h"
#import "LYBalanceViewController.h"

@interface PMineWalletViewController ()

@property (nonatomic, strong) UIButton *recruitmentBtn;
@property (nonatomic, strong) UIButton *balanceBtn;

@property (nonatomic, strong) LYRecruitmentController *recruitmentVC;
@property (nonatomic, strong) LYBalanceViewController *blanceVC;
@property (nonatomic, strong) UIView *currentVC;

@end

@implementation PMineWalletViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createSubview];
}

- (void)createSubview{
    UIView *titleview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 130, 40)];
    titleview.backgroundColor = [UIColor whiteColor];
    self.navigationItem.titleView = titleview;
    
    self.recruitmentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [titleview addSubview:self.recruitmentBtn];
    self.recruitmentBtn.frame = CGRectMake(0, 0, 60, 40);
    [self.recruitmentBtn addTarget:self action:@selector(recruitmentBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.recruitmentBtn setTitle:@"聘 豆" forState:UIControlStateNormal];
    [self.recruitmentBtn setTitleColor:RGB(34, 34, 34) forState:UIControlStateNormal];
    [self.recruitmentBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    self.recruitmentBtn.selected = YES;
    self.recruitmentBtn.userInteractionEnabled = NO;
    self.recruitmentBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    
    self.balanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [titleview addSubview:self.balanceBtn];
    self.balanceBtn.frame = CGRectMake(70, 0, 60, 40);
    [self.balanceBtn addTarget:self action:@selector(balanceBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.balanceBtn setTitle:@"余 额" forState:UIControlStateNormal];
    [self.balanceBtn setTitleColor:RGB(34, 34, 34) forState:UIControlStateNormal];
    [self.balanceBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    self.balanceBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    
    
    self.recruitmentVC = [[LYRecruitmentController alloc] init];
    [self addChildViewController:self.recruitmentVC];
    [self.view addSubview:self.recruitmentVC.view];
    self.currentVC = self.recruitmentVC.view;
    
    self.blanceVC = [[LYBalanceViewController alloc] init];
    [self addChildViewController:self.blanceVC];
}

#pragma mark -- Action
- (void)recruitmentBtnClick:(UIButton *)button{
    self.balanceBtn.selected = NO;
    self.balanceBtn.userInteractionEnabled = YES;
    self.balanceBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    button.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    button.selected = YES;
    button.userInteractionEnabled = NO;
    [self.currentVC removeFromSuperview];
    [self.view addSubview:self.recruitmentVC.view];
    self.currentVC = self.recruitmentVC.view;
}

- (void)balanceBtnClick:(UIButton *)button{
    self.recruitmentBtn.selected = NO;
    self.recruitmentBtn.userInteractionEnabled = YES;
    self.recruitmentBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
    button.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    button.selected = YES;
    button.userInteractionEnabled = NO;
    [self.currentVC removeFromSuperview];
    [self.view addSubview:self.blanceVC.view];
    self.currentVC = self.blanceVC.view;
}

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
//    return 1;
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return self.dataArray.count;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    LYSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_LYSettingCell forIndexPath:indexPath];
//    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//    NSString *name = self.dataArray[indexPath.row];
//    if (indexPath.row == 5) {
//        [cell setTitle:name detail:@"邀请一位赚3元"];
//        cell.detaillabel.textColor = [UIColor redColor];
//    }else{
//        [cell setTitle:name detail:@""];
//    }
//    return cell;
//}
//
//#pragma mark -- UITableViewDelegate
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    [self jumpToVC:indexPath.row];
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 45.0;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    return 0.001;
//}
//
//-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
//    return 0.0f;
//}
//
//#pragma mark --Data
//- (void)requestData{
//    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
//    dic = [UIToolsControl getPublicParameter];
//    __weak typeof(self) weakSelf = self;
//    [BaseNetManager requestWithMethod:POST path:Wallet_amount_URL params:dic successBlock:^(NSDictionary *responseObject) {
//        if ([responseObject[@"code"] integerValue] == 2000) {
//            //钱包信息
//            CGFloat amount = [responseObject[@"data"][@"amount"] floatValue];
//            weakSelf.balanceLabel.text = [NSString stringWithFormat:@"%.2f",amount];
//            NSString *str = weakSelf.balanceLabel.text;
//            if ([[str substringFromIndex:str.length-2] isEqualToString:@"00"]) {
//                str = [str substringToIndex:str.length-3];
//                weakSelf.balanceLabel.text = str;
//            }else if ([[str substringFromIndex:str.length-1] isEqualToString:@"0"]){
//                weakSelf.balanceLabel.text = [str substringToIndex:str.length-1];
//            }
//
//        }else{
//            SVPHUDError(responseObject[@"msg"]);
//        }
//    } failurBlock:^(NSError *error) {
//        SVPHUDError(NetErrorAlertText);
//    }];
//}

//#pragma mark -- Acion
//- (void)jumpToVC:(NSInteger)index{
//    __weak typeof(self) weakSelf = self;
//    switch (index) {
//        case 0:{
//            LYRechargeController *rechargeVC = [[LYRechargeController alloc] init];
//
//            [self.navigationController pushViewController:rechargeVC animated:YES];
//        }
//            break;
//        case 1:{
//            LYWithdrawController *withdrawVC = [[LYWithdrawController alloc] init];
//            [self.navigationController pushViewController:withdrawVC animated:YES];
//        }
//            break;
//        case 2:{
//            LYWithDrawListController *withdrawListVC = [[LYWithDrawListController alloc] init];
//            [self.navigationController pushViewController:withdrawListVC animated:YES];
//        }
//            break;
//        case 3:{
//            LYIncomeBreakdownController *incomVC = [[LYIncomeBreakdownController alloc] init];
//            incomVC.amount = self.balanceLabel.text;
//            incomVC.block = ^(NSString *amount){
//                weakSelf.balanceLabel.text = [NSString stringWithFormat:@"%.1f",[amount floatValue]];
//            };
//            [self.navigationController pushViewController:incomVC animated:YES];
//        }
//            break;
//        case 4:{
//            LYExpendituresDetailController *expenditureVC = [[LYExpendituresDetailController alloc] init];
//            expenditureVC.amount = self.balanceLabel.text;
//            expenditureVC.block = ^(NSString *amount){
//                weakSelf.balanceLabel.text = [NSString stringWithFormat:@"%.1f",[amount floatValue]];
//            };
//            [self.navigationController pushViewController:expenditureVC animated:YES];
//        }
//            break;
//        case 5:{
//            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
//            GWVC.showType = GeneralWebViewTypeOfInviteFriend;
//            GWVC.hidesBottomBarWhenPushed = YES;
//            [self.navigationController pushViewController:GWVC animated:YES];
//
//        }
//            break;
//    }
//}

//-(NSArray *)dataArray{
//    if (!_dataArray) {
//        _dataArray = @[@"充值", @"提现",@"提现明细", @"收入明细", @"支出明细", @"邀请好友"];
//    }
//    return _dataArray;
//}


@end
